Conda environment management

1 minute read

Published:

Conda environment management

documentation link

1. Important commands

  1. Check existing environments conda env list
    • Warning: env before list, if you type conda list env, if will show the packages installed in one of the environments.
  2. Create an environment
    conda create -n myenv
    

    or

    conda create --name myenv
    
    • if we want to create enviroment with specific python version:
      conda create -n myenv python=3.6
      
    • if we want to create environment with specific packages with specific version:
conda create -n myenv scipy=0.15.0 numpy 

  • we can also install packages after creating environment.
conda install -n myenv scipy
  • To clone(duplicate) an environment
conda create --name newenv --clone myenv
  1. Remove an environment
    conda remove -n myenv --all
    
    • verify the delete by
      conda info --envs 
      

      or

      conda env list 
      
  2. Activate an environment
    conda activate myenv
    
    • Warning: there is no need for argument ‘-n’
  3. Deactivate an environment
    conda deactivate
    
  4. Check packages in a specific environment
    conda list -n myenv
    
    • Or, if the env is already activated
      conda list 
      
    • If we only want to check if a specific package is installed
      conda list -n myenv scipy
      

2. Conda vs pip

  • pip is a package manager only for Python
  • venv is a environment manager only for Python
  • conda is both a package and environment manager and is language agnostic(works with any languages)

3. Why it always showing module not found, even I have already installed it?

  • Remember to use conda install instead of pip install